cmake_minimum_required(VERSION 3.0)
project(tempc VERSION 1.0 LANGUAGES C)

#编译参数
add_compile_options(-Wall -O2 -std=gnu11)

#设定编译类型
set(CMAKE_BUILD_TYPE Release)


#MESSAGE: STATUS(一般信息),SEND_ERROR(会跳过),FATAL_ERROR(立即终止)
message(STATUS "CMAKE_PROJECT_NAME = ${CMAKE_PROJECT_NAME}")
message(STATUS "PROJECT_SOURCE_DIR = ${PROJECT_SOURCE_DIR}")

#设定目录含义
set(CMAKE_SOURCE_DIR src)
set(EXECUTABLE_OUTPUT_PATH bin)
include_directories(inc)
#target_include_directories(inc)
set(LIBRARY_OUTPUT_PATH lib)
link_directories(lib)
link_directories(../lib)


add_library(msgd src/msgd.c)
add_library(rgb src/rgb.c)
add_library(temp src/temp.c)
add_library(fan src/fan.c)
add_library(oled src/oled.c)
add_library(ssd1306_i2c src/ssd1306_i2c.c)

add_executable(tempcd maind.c)
add_executable(tempc main.c)

target_link_libraries(temp msgd)
target_link_libraries(rgb wiringPi temp)
target_link_libraries(fan wiringPi temp)
target_link_libraries(ssd1306_i2c wiringPi)
target_link_libraries(oled wiringPi temp ssd1306_i2c)
target_link_libraries(tempcd wiringPi rgb temp fan pthread ssd1306_i2c oled)


set(CMAKE_INSTALL_PREFIX /usr)
install(TARGETS tempcd DESTINATION bin)
install(TARGETS tempc DESTINATION bin)
install(FILES tempcd.service DESTINATION lib/systemd/system/)
